package com.ryg.chapter_3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;

public class MainActivity extends Activity {

    private Button mButton;
    private Animation mAnimation ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mButton = (Button) findViewById(R.id.button4);
        mAnimation = AnimationUtils.loadAnimation(this,R.anim.translate);

    }

    public void onButtonClick(View v) {
        if (v.getId() == R.id.button1) {
            Intent intent = new Intent(this, TestActivity.class);
            startActivity(intent);
        } else if (v.getId() == R.id.button2) {
            Intent intent = new Intent(this, DemoActivity_1.class);
            startActivity(intent);
        } else if (v.getId() == R.id.button4) {
            int lLeft = mButton.getLeft();
            int lTop = mButton.getTop();
            float lx = mButton.getX();
            float ly = mButton.getY();
            float lx1 = mButton.getTranslationX();
            float ly1 = mButton.getTranslationY();

            mButton.startAnimation(mAnimation);
//            mButton.requestLayout();
             lLeft = mButton.getLeft();
             lTop = mButton.getTop();
             lx = mButton.getX();
             ly = mButton.getY();
             lx1 = mButton.getTranslationX();
             ly1 = mButton.getTranslationY();
            float ly2 = mButton.getY();
        } else if (v.getId() == R.id.button3) {
            int lLeft = mButton.getLeft();
            int lTop = mButton.getTop();
            float lx = mButton.getX();
            float ly = mButton.getY();
            float lx1 = mButton.getTranslationX();
            float ly1 = mButton.getTranslationY();
            Intent intent = new Intent(this, DemoActivity_2.class);
//            startActivity(intent);
        }
    }
}
